package solitaire.deck;

public enum Rank {
	     
	Ace(0), Two(1), Three(2), Four(3), Five(4), Six(5), Seven(6), Eight(7), Nine(8), Ten(9), Jack(10), Queen(11), King(12);
        
	private int rankNr;       
        
	private Rank(int nr){
		rankNr = nr;
	}    
        
	public int getNr(){
		return rankNr;
	} 
	
	public static Rank getRankNumber(int rankNumber){
            

		if(rankNumber < 0 || rankNumber  >12){

			throw new IllegalArgumentException("The rank number should be in the range [0,11].");
		}
            
		switch(rankNumber){
    		case 0:
    			return Ace;
    		case 1:
    			return Two;
    		case 2:
    			return Three;
    		case 3:
    			return Four;
    		case 4:
    			return Five;
    		case 5:
    			return Six;
    		case 6:
    			return Seven;
    		case 7:
    			return Eight;
    		case 8:
    			return Nine;
    		case 9:
    			return Ten;
    		case 10:
    			return Jack;
    		case 11:
    			return Queen;
    		case 12:
    			return King;
    		default:
    			throw new IllegalArgumentException("Don't know what to do with the number " +rankNumber);                       
		}
	}
}
